package com.ztgf.commodity.api.client;

import com.ztgf.commodity.models.service.ICommodityCategoryParamRelationService;
import com.ztgf.commodity.models.vo.CommodityCategoryParamRelationVO;
import com.ztgf.common.constant.Result;
import com.ztgf.common.enums.CodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品分类参数关系表控制器
 *
 * @author chenyu.wang
 * @Date 2020-06-15 10:30:06
 */

@RestController
@RequestMapping(value = "/api/commodityCategoryParamRelation")
@Slf4j
@Api(value = "CommodityCategoryParamRelationApiController", tags = "商品分类参数关系表Api接口")
public class CommodityCategoryParamRelationApiController {

    @DubboReference
    private ICommodityCategoryParamRelationService commodityCategoryParamRelationService;

    @PostMapping(value = "/queryCategoryParamList")
    @ApiOperation(value = "根据顶级分类id获取商品参数信息", notes = "根据顶级分类id获取商品参数信息")
    public Result<List<CommodityCategoryParamRelationVO>> queryCategoryParamList(Long categoryId, Long brandId, String filterName) {
        if (null == categoryId || null == brandId) {
            return new Result<>(CodeEnum.FAIL_100002);
        } else {
            List<CommodityCategoryParamRelationVO> list = commodityCategoryParamRelationService.queryList(categoryId, brandId, filterName);
            return new Result<>(list);
        }
    }

}
